package com.wash.shoes.domain.dto;

import cn.hutool.core.collection.CollectionUtil;
import com.ruoyi.common.core.domain.model.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
@ApiModel(value = "订单入库请求对象new")
public class ShoeCheckInDto extends BaseModel {

    @ApiModelProperty(value = "订单的Id")
    @NotNull(message = "订单id不能为空")
    private String orderId;

    @ApiModelProperty(value = "物品类型")
    @NotNull(message = "物品类型不能为空")
    private String itemType;

    @ApiModelProperty(value = "水洗码")
    @NotNull(message = "水洗码不能为空")
    private String washCode;
/*    @ApiModelProperty(value = "配件的图片")
    private String fittingImg;*/

    @ApiModelProperty(value = "配饰记录")
    private List<AccessorieRecord> accessorieRecords;

    @ApiModelProperty(value = "鞋子的图片")
    @NotNull(message = "鞋子图片不能为空")
    private List<ShoeImgDto> shoeImgDtoList = new ArrayList<>();
    @ApiModelProperty(value = "商家备注")
    private List<String> remark;


    public void validate() {
        if (CollectionUtil.isNotEmpty(shoeImgDtoList)) {
            boolean exist = shoeImgDtoList.stream().map(ShoeImgDto::getShoeImg).collect(Collectors.toList()).contains("null");
            if (exist) {
                throw new RuntimeException(" shoeImgDtoList 中有null元素");
            }
        }
    }

    public static void main(String[] args) {
        ShoeCheckInDto shoeCheckInDto = new ShoeCheckInDto();
        List<ShoeImgDto> shoeImgDtoList = new ArrayList<>();
        ShoeImgDto shoeImgDto = new ShoeImgDto();
        ShoeImgDto shoeImgDto1 = new ShoeImgDto();
        ShoeImgDto shoeImgDto2 = new ShoeImgDto();
        ShoeImgDto shoeImgDto3 = new ShoeImgDto();
        shoeImgDto.setShoeImg("111");
        shoeImgDto1.setShoeImg("111");
        shoeImgDto2.setShoeImg("111");
        shoeImgDto3.setShoeImg("11");
        shoeImgDtoList.add(shoeImgDto);
        shoeImgDtoList.add(shoeImgDto1);
        shoeImgDtoList.add(shoeImgDto2);
        shoeImgDtoList.add(shoeImgDto3);
        shoeCheckInDto.setShoeImgDtoList(shoeImgDtoList);
        shoeCheckInDto.validate();
    }

    /**
     * 配饰记录
     */
    @ApiModel(value = "配饰记录")
    @Data
    public static class AccessorieRecord extends BaseModel {
        @ApiModelProperty(value = "配饰类型")
        private String itemType;
        @ApiModelProperty(value = "图片")
        private List<String> images;
        @ApiModelProperty(value = "配饰水洗码")
        private String washCode;
    }
}